<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.*" %>
<%@ page import="org.news.entity.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/allNews.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/seleAllNews.js"></script>
<title>全部用户</title>
<%
    admin admin=(admin)session.getAttribute("userInfo");
    List<manager> managers=(List<manager>)request.getAttribute("managers");
%>
</head>
<body>
<!-- 页面头部   -->
<header id="header_div">
  <div class="container">
	<div class="logo left">
		<img src="${pageContext.request.contextPath}/img/logo2.jpg" width="700" height="90">
	</div>
	<ul class="right">	
	    <%if(admin==null){ %>
	    <li id="info1"><a href="${pageContext.request.contextPath}/view/login/login.jsp">登录？</a></li>
	    <%} else{%>
	    <li id="info1"><a>欢迎您：<%=admin.getUname() %>[管理员]</a></li>
	    <%} %>
	    <li id="info2"><a href="${pageContext.request.contextPath}/view/login/addMg.jsp">马上注册</a></li>
		<li><a href="${pageContext.request.contextPath}/view/News/addNew.jsp">添加新闻</a></li>
		<li><a href="${pageContext.request.contextPath}/upAndDownServlet/allFiles">管理新闻文件</a></li>	
		<li><a href="${pageContext.request.contextPath}/index.jsp">返回主页</a></li>
	</ul>
  </div>
</header>
<!-- 大体部分 -->
<h4 align="center" style="position: relative;font-size: 20px;margin-top: 20px;"> 全部用户</h4>
<div id="table_div">

<table id="table">
    <tr>
       <th>登录名</th>
       <th>姓名</th>
       <th>密码</th>
       <th>管理操作</th>
    </tr>
    <% if(managers!=null){ for(manager mg:managers){%>
    <tr>
        <td width="20%"><%=mg.getId() %></td>
        <td width="15%"><%=mg.getUname() %></td>
        <td width="13%"><%=mg.getUpwd() %></td>
        <td width="10%">
            <button onclick="getMgInfo('<%=mg.getId()%>')">修改信息</button>
            <button onclick="deleMgById('<%=mg.getId()%>')">删除</button>
        </td>
    </tr>
    <%           }     } %>

</table>
</div>
<!--页脚部分-->
<div id="footer">
	<div class="container">
		<p>
			<img src="img/i-f-logo.png"> <span>@2020 北京市xxxxxxx</span>
			 <a href="#">版权说明</a> <a href="#">版权说明</a> <a href="#">版权说明</a> 
			 <a href="#">版权说明</a> <a href="#">版权说明</a>
		</p>
	</div>
</div>
<script type="text/javascript">
function deleMgById(mgId) {
	//id是用户名
	var mgId=mgId;
	var check=confirm("确认删除吗？");
	if(check){
		$.ajax({
			url:"/NewsManager_SSM/admin/deleMgById",
			type:"post",
			data:"uid="+mgId, 
			success:function(result,testStatus)
			{
				if(result == "1"){
					alert("删除成功");
					 location.reload();
				}
			},
			error:function(xhr,errrorMessage,e){
				alert("系统异常！");
			}
		});
	}else{
		return false;
	}
	
	}
function getMgInfo(nid){
	var id=nid;
	location.href="/NewsManager_SSM/admin/getMgInfoById/?uid="+id;
}




</script>
</body>
</html>